// ----------------------------------
// RSDK Project: Sonic Essence
// Script Description: Cave Detail
// Script Author: Tails LP, Xanman
// ----------------------------------

// Aliases

// Function declarations
private alias object.value1 : WALL_HEIGHT
private alias object.value0 : WALL_LENGTH

event ObjectMain
end event


event ObjectDraw
		temp3 = 0
		temp4 = 0
		while temp3 <= WALL_LENGTH

			temp0 = object.xpos
			temp1 = 0x800000
			temp1 *= temp3
			temp0 += temp1
			temp2 = WALL_LENGTH
			temp0 -= temp2

			while temp4 <= WALL_HEIGHT
				temp5 = object.ypos
				temp6 = 0x800000
				temp6 *= temp4
				temp5 -= temp6
				temp7 = WALL_HEIGHT
				temp5 += temp7
				DrawSpriteXY(0, temp0, temp5)
				temp4 ++
			loop
			DrawSpriteXY(1, temp0, temp5)

			temp4 = 0

			DrawSpriteXY(0, temp0, object.ypos)
				
			temp3 ++
		loop

end event


event ObjectStartup
	object[1013].type = TypeName[Cave Detail]
	object[1013].priority = PRIORITY_ACTIVE

	// Set each ring's draw order to 4
	foreach (TypeName[Cave Detail], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 2
		object[arrayPos0].priority = PRIORITY_ACTIVE
	next

	CheckCurrentStageFolder("WIZ")
	if checkResult == true
		LoadSpriteSheet("WIZ/Objects.gif")
		SpriteFrame(-8, -121, 128, 128, 188, 383)
		SpriteFrame(-8, -141, 128, 20, 188, 362)
	end if

	CheckCurrentStageFolder("SSZ")
	if checkResult == true
		LoadSpriteSheet("SSZ/Objects.gif")
		SpriteFrame(-8, -121, 128, 128, 100, 383)
		SpriteFrame(-8, -141, 128, 20, 100, 362)
	end if

end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
